# from selenium import webdriver
# from selenium.webdriver.support.wait import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from selenium.webdriver.common.by import By
# from selenium.webdriver.chrome.options import Options
from urllib.parse import unquote, quote
from bs4 import BeautifulSoup
import requests, time, random, os

# login_headers = {
#             'Accept': 'application/json, text/plain, */*',
#             'Accept-Encoding': 'gzip, deflate, br',
#             'Accept-language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
#             'Cache-Control': 'no-cache',
#             'Connection': 'keep-alive',
#             'Host': 'm.weibo.cn',
#             'mweibo-pwa': '1',
#             'origin': 'https://m.weibo.cn',
#             'Pragma': 'no-cache',
#             'x-requested-with': 'XMLHttpRequest',
#             'TE': 'Trailers',
#             # 'Referer': 'https://m.weibo.cn/u/3669102477',
#             'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0',
#             'Cookie': 'SUHB=0Ryq2eSVEeadqW; SCF=ArirHZExzlW5bKSrauUZaAFh_Vhzd2cGgYuyIKFqsjlxeayPOni3vUE6fWK6oSxNlj7vpp_hh6VJ4HLezE0l3rI.; ALF=1550989845; _T_WM=0cf6995511847dc74426ecfbd5569f80; hibext_instdsigdipv2=1; MLOGIN=1; XSRF-TOKEN=626580; WEIBOCN_FROM=1110006030; M_WEIBOCN_PARAMS=luicode%3D10000011%26lfid%3D1076033669102477%26fid%3D1005053669102477%26uicode%3D10000011; SSOLoginState=1548399547; SUB=_2A25xTsPrDeRhGeBI7lQS8SzOwj2IHXVSsO2jrDV6PUJbktAKLUelkW1NRpVacUuggETrcW0b4qn0TLhpxjGERUbA; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WWEzR_Ukb14DGjFU3TamRn05JpX5K-hUgL.FoqcSKq0eKzE1K22dJLoI02LxKqL1KMLBK5LxKqL1K-L12eLxKqL1K.L1KeLxKqL1K.L1KeLxK-LB.eLB.2Eeh5E'
#             # 'Cookie': '_T_WM=0066bbafbec70e4b74b6ff88f78957c0; hibext_instdsigdipv2=1; from=1110006030; WEIBOCN_FROM=1110006030; MLOGIN=1; M_WEIBOCN_PARAMS=lfid%3D102803%26luicode%3D20000174%26fid%3D1005053669102477%26uicode%3D10000011; SUB=_2A252mnLODeRhGeBI7lQS8SzOwj2IHXVSZR6GrDV6PUJbkdANLWHFkW1NRpVacR40_3yHTfIjsjYTfqN71FsZ1QM3; SUHB=079j8qxb09Qc_T; SCF=AsfcBVjiz0kcskVtMDqUdIezE3sxu6PbZHnm6NGIZSsxapLvtpOzc8_9QYkVYCmqAfw8AYtorZOYV_p0p5RQAmg.; SSOLoginState=1537082014'
#         }
# params = {'type': 'uid', 'value': '3669102477', 'containerid': '1076033669102477'}
session = requests.Session()
# r = session.get('https://video.weibo.com/media/play?livephoto=//us.sinaimg.cn/0012NIyAjx07zC72HVwb0f0f0100bjka0k01.mov&KID=unistore,videomovSrc')
video = requests.get('https://video.weibo.com/media/play?livephoto=//us.sinaimg.cn/0012NIyAjx07zC72HVwb0f0f0100bjka0k01.mov&KID=unistore,videomovSrc')
with open('0012NIyAjx07zC72HVwb0f0f0100bjka0k01.mov', 'wb') as video_file:
    video_file.write(video.content)
# print(r.headers)
